﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace VersionComparer.DataModel.Actions
{
    public abstract class SpecificAction : Action
    {
        #region fields
        ActionAttribute attribute;
        Keys shortcutKeys;
        #endregion fields

        #region properties
        private ActionAttribute Attribute
        {
            get
            {
                if ( attribute == null )
                {
                    object[] attributes = GetType().GetCustomAttributes(typeof (ActionAttribute) ,  true);
                    if (attributes.Length == 0)
                        return null;
                    attribute = attributes[0] as ActionAttribute;
                }
                return attribute;
            }
        }
        public bool IsValid
        {
            get
            {
                return Attribute != null;
            }
        }
        public int Index
        {
            get
            {
                return Attribute == null ? 0 : Attribute.Index;
            }
        }
                public override string DisplayName
        {
            get
            {
                return Attribute == null ? null : Attribute.DisplayName;
            }
        }
        public override Keys ShortcutKey
        {
            get
            {
                if ( shortcutKeys == Keys.None )
                    shortcutKeys = Attribute == null ? Keys.None : Attribute.ShortcutKey;
                return shortcutKeys;
            }
            set
            {
                shortcutKeys = value;
            }
        }
        #endregion properties

    
    }
}
